import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: 'home',
        component: () => import('@/views/home/index'),
        name: 'Dashboard',
        meta: { title: '首页', icon: 'dashboard', affix: true }
      }
    ]
  },

  {
    path: '/homePage',
    component: Layout,
    redirect: '/homePage/banner',
    name: 'homePage',
    meta: { title: '官网首⻚配置' },
    children: [
      {
        path: 'banner',
        name: 'banner',
        component: () => import('@/views/home-page/banner/index'),
        meta: { title: '首⻚轮播图' }
      },
      {
        path: 'navs',
        name: 'navs',
        component: () => import('@/views/home-page/navs/index'),
        meta: { title: '导航栏' }
      },
      {
        path: 'footer',
        name: 'footer',
        component: () => import('@/views/home-page/footer/index'),
        meta: { title: '底部信息' }
      },
      {
        path: 'left',
        name: 'left',
        component: () => import('@/views/home-page/left/index'),
        meta: { title: '左侧内容' }
      },
      {
        path: 'right',
        name: 'right',
        component: () => import('@/views/home-page/right/index'),
        meta: { title: '右侧内容' }
      }
    ]
  },
  {
    path: '/student',
    component: Layout,
    redirect: '/student/student',
    name: 'student',
    meta: { title: '学员管理', icon: 'info' },
    children: [
      {
        path: 'student',
        name: 'studentInfo',
        component: () => import('@/views/student/info/index'),
        meta: { title: '学员信息录入' }
      },
      {
        path: 'sign',
        name: 'studentSignInfo',
        component: () => import('@/views/student/sign/index'),
        meta: { title: '学员登录信息' }
      }
    ]
  },
  {
    path: '/news',
    component: Layout,
    redirect: '/product/nav',
    name: 'news',
    meta: { title: '新闻资讯配置', icon: 'info' },
    children: [
      {
        path: 'detail',
        name: 'newsDetail',
        component: () => import('@/views/news/index'),
        meta: { title: '新闻资讯配置' }
      },
      {
        path: 'type',
        name: 'newsType',
        component: () => import('@/views/news-type/index'),
        meta: { title: '新闻资讯类型' }
      },
      {
        path: 'left',
        name: 'left',
        component: () => import('@/views/details-config/left'),
        meta: { title: '左侧内容' }
      }
    ]
  },
  // {
  //   path: '/vocation',
  //   component: Layout,
  //   redirect: '/vocation/vacation',
  //   name: 'vocation',
  //   meta: { title: '学校专业配置', icon: 'elearn' },
  //   children: [
  //     {
  //       path: 'vocation',
  //       name: 'VOCATION',
  //       component: () => import('@/views/vocation/index'),
  //       meta: { title: '专业配置' }
  //     },
  //     {
  //       path: 'classes',
  //       name: 'CLASSES',
  //       component: () => import('@/views/classes/index'),
  //       meta: { title: '专业班级' }
  //     }
  //   ]
  // },
  {
    path: '/others',
    component: Layout,
    redirect: '/others/STANDER',
    name: 'others',
    hidden: true,
    meta: { title: '基础配置', icon: 'elearn' },
    children: [
      {
        path: 'basicConfig',
        name: 'BASIC_CONFIG',
        component: () => import('@/views/basicConfig/index'),
        meta: { title: '公共基础配置' }
      },
      {
        path: 'contentConfig',
        name: 'CONTENT_CONFIG',
        component: () => import('@/views/contentConfig/index'),
        meta: { title: '区域内容配置' }
      },
      {
        path: 'formConfig',
        name: 'FORM_CONFIG',
        component: () => import('@/views/formConfig/index'),
        meta: { title: '基础表单配置' }
      }
    ]
  },

  {
    path: '/photo',
    component: Layout,
    redirect: '/photo/index',
    name: 'setting',
    meta: { title: '图片设置', icon: 'elearn' },
    children: [
      {
        path: 'index',
        name: 'photoIndex',
        component: () => import('@/views/photoConfig/album/index'),
        meta: { title: '图片集管理' }
      }
    ]
  },
  {
    path: '/otherPage',
    component: Layout,
    redirect: '/otherPage/signGuide/index',
    name: 'setting',
    meta: { title: '其他页面设置', icon: 'elearn' },
    children: [
      {
        path: 'signGuide/index',
        name: 'settingIndex',
        component: () => import('@/views/otherPages/signGuide/index'),
        meta: { title: '报名指引' }
      }
    ]
  },
  {
    path: '/setting',
    component: Layout,
    redirect: '/setting/index',
    name: 'setting',
    meta: { title: '系统设置', icon: 'elearn' },
    children: [
      {
        path: 'index',
        name: 'settingIndex',
        component: () => import('@/views/setting/changepwd/index'),
        meta: { title: '修改密码' }
      }
    ]
  }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
